<template>
  <MapContainer @onload="mapOnload" />
</template>
<script setup lang="ts">
import MapContainer from '../components/MapContainer.vue'
import MapDriving from '../components/MapDriving.vue'
import AMapLoader from "@amap/amap-jsapi-loader";
import AMap from 'vue-amap';
import { onMounted } from 'vue';
let myMap: AMap.Map;
function mapOnload(map: AMap.Map) {
  myMap = map;
  let positionArr = [
    [113.357224, 34.977186],
    [114.555528, 37.727903],
    [112.106257, 36.962733],
    [109.830097, 31.859027],
    [116.449181, 39.98614],
  ];
  for (let item of positionArr) {
    let marker = new AMap.Marker({
      position: [item[0], item[1]],
    });
    marker.setMap(myMap);
  }
  //实时路况图层
  var trafficLayer = new AMap.TileLayer.Traffic({
    zIndex: 10
  });
  myMap.add(trafficLayer);//添加图层到地图

}
 
</script>